VT-d: fix iommu_domid for PCI/PCIx devices assignment
authorKeir Fraser <keir.fraser@citrix.com>
Mon, 4 Jan 2010 09:07:28 +0000 (09:07 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Mon, 4 Jan 2010 09:07:28 +0000 (09:07 +0000)
commitdec403cc668f4f13089a361248c02f2252a126a8
tree93d9b81c8bc37131c5fca5262db1a6625c900554
parent07d20ae391d1cc8acd3f8d0c9bcbd9aa109dced5
VT-d: fix iommu_domid for PCI/PCIx devices assignment

Currently, it clears iommu_domid and domid_map at the end of
domain_context_unmap_one() if no other devices under the same iommu
owned by this domain. But, when assign a PCI/PCIx device to a guest,
it also assigns its upstream bridge to the guest, and they use the
same iommu_domid. In the deassignment, the iommu_domid and domid_map
are cleared in domain_context_unmap_one() for the assigned PCI/PCIx
device, therefore it cannot get valid iommu_domid in followed
domain_context_unmap_one for its upstream bridge. It causes PCI/PCIx
device re-assignment failure.

This patch moves the iommu_domid and domid_map clearing code to the
end of domain_context_unmap, where all dependent
domain_context_unmap_one()s are completed, thus fix above issue.

Signed-off-by: Weidong Han <Weidong.han@intel.com>
xen/drivers/passthrough/vtd/iommu.c